<?php
include ("boot.php");

//$oADODB->debug = true;
// ==========================================================================
// User Class
// ==========================================================================

$oFolder = new daoLinks($oADODB);
$oRelation = new daoRelLinks($oADODB);

// removes slashes
$sViewdb = stripslashes($_GET['viewdb']);

// decode json recieved from Bindows to Array
$aRequest = json_decode($sViewdb, true);

// folder
$aRequestSave['iUseID'] = $_SESSION['iUseID'];
$aRequestSave['vLnkName'] = $aRequest['vLnkName'];
$oFolder->save($aRequestSave);

// relation
$aRequestRel['iRelChildID'] = $oFolder->iLastID;
$aRequestRel['iRelParentID'] = $aRequest['iRelParentID'];
$oRelation->save($aRequestRel);

// return menu
$o = new Menu;
$oResponse->oMenu = $o->getMenu();

// print response
echo json_encode($oResponse);
?>